home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / pau_50.zip / PAU-50.ASM < prev    next >
Assembly Source File  |  1989-05-11  |  4KB  |  130 lines

  1.  
  2. PAGE ,132
  3. TITLE PAU.COM - "Shipdisk" Utility
  4.  
  5. COMMENT {  PAU.COM is a program to move the fixed-disk head
  6. to a safe "Landing-Zone" (cylinder 306 on a standard PC/XT disk).
  7. Should be used before powering-down a system with a hard disk to
  8. prevent damage from shock, vibration, etc.
  9.  
  10. NOTE:   Format for hard disk cylinders/sectors in register cx is:
  11. |-------------- CH ----------------|----------------- CL ---------------|
  12. |                |                 |                   |                |
  13. | 15  14  13  12 |  11  10   9   8 |   7   6 |   5   4 |   3   2   1   0|
  14. | c7  c6  c5  c4 |  c3  c2  c1  c0 |  c9  c8 |  s5  s4 |  s3  s2  s1  s0|
  15.                                              |
  16. |-----------------  CYLINDERS  --------------|-------- SECTORS ---------|
  17. |    Max. number of cylinders = 1024         | Max. Sectors/Track = 64  |
  18. {
  19.  
  20. ;=-=-=-=-=-=-=-=-=-= MACROS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  21. COMMENT    {    This macro will, by successive subtraction, convert the
  22. binary number in AX into ASCII characters which will be output one at
  23. a time, as translated.  A value of 20h in DH will cause leading zeros
  24. to be suppressed, otherwise enter with a value of 30h.  Registers
  25. AX and DX are destroyed.
  26. {
  27. CYL2ASC    MACRO    VALUE
  28.     local    subtr, toofar, z_out
  29.     xor    dl,dl        ;;clear dl (counter).
  30. subtr:    sub    ax, VALUE    
  31.     jc    toofar        ;;subtract went negative
  32.     inc    dl        ;;increment counter
  33.     jmp    subtr        ;;loop for successive subtr.
  34. toofar:    add    ax,VALUE    ;;restore ax.
  35.     or    dl,dl        ;;test if count is 0.
  36.     jz    z_out
  37.     mov    dh,30h        ;;If non-zero, convert to numeric.
  38. z_out:    add    dl,dh        ;;Convert to ASCII.
  39.     push    ax
  40.     mov    ah,02h        ;;DOS out_char function.
  41.     int    21h
  42.     pop    ax
  43. ENDM
  44. ;==================================================================
  45. CYL1ASC    MACRO        ;;Use this MACRO instead of divide-by-one
  46.     mov    dl,al
  47.     add    dl,30h        ;Always make this digit numeric.
  48.     mov    ah,02h
  49.     int    21h
  50.     lea    dx,MESG5    ;Add spaces (3) at end.
  51.     mov    ah,9
  52.     int    21h
  53. ENDM
  54. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55. PAU    segment
  56.     assume     cs:PAU, ds:PAU
  57.     org    100h
  58. START:    jmp    START_CODE
  59.  
  60. ;^^^^^^^^^^^^^^^^^^^^^^^^ DATA ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  61. BANNER    db    'PAU.COM -- Ver. 5.0 (J.Borza 4/89)',0Dh,0Ah
  62.     db    '"Shipdisk" Utility for one or two hard disk drives'
  63. CRLF    db    0Dh,0Ah,0Ah,'$'
  64. MESG1    db    'No fixed-disks found!',0Dh,0Ah,'$'
  65. MESG2    db    'Hard Disk parked.',0Dh,0Ah,'$'
  66. MESG3    db    'Both Hard Disks parked.',0Dh,0Ah,'$'
  67. MESG4    db    'Cylinder: $'
  68. MESG5    db    '   $'        ;Pad spaces (3)
  69. ;^^^^^^^^^^^^^^^^^^^^^^^ CODE ^^^^^^^^^^^^^^^^^^^
  70. START_CODE:
  71.     mov    dx, offset BANNER    ;display banner
  72.     mov    ah,9
  73.     int     21h
  74.     mov    dx,80h        ;1st hard disk.
  75.     call    SEEK        ;Try parking 1st disk.
  76.     jc    NO_DSK        ;Oops - no disk(s).
  77.     mov    dx,81h        ;2nd hard disk.
  78.     call    SEEK        ;Try parking 2nd disk.
  79.     jc    ONE_DSK        ;Oops - only one disk.
  80.     lea    dx,MESG3    ;Both Disks......
  81.     jmp    PUTOUT
  82. ONE_DSK:
  83.     lea    dx,MESG2    ;Fixed disk....
  84.     jmp    PUTOUT
  85. NO_DSK:
  86.     lea    dx,MESG1    ;No disks installed......
  87. PUTOUT:
  88.     mov    ah,9        ;print the message
  89.     int    21h
  90.     mov    ax,4C00h    ;Exit (ECODE=0)
  91.     int    21h
  92. ;------------------------------------------------------------------
  93. SEEK    proc    near
  94.     push    dx        ;Preserve dx thru BIOS call
  95.     clc
  96.     mov    ah,08h        ;Get drive parms
  97.     int    13h
  98.     jnc    PARMS_GOT    ;Continue if OK else,
  99.     ret            ;return with carry set.
  100. PARMS_GOT:
  101.     mov    ah,0Ch        ;Seek to end.
  102.     pop    dx        ;Cleanup dx
  103.     int    13h        ;Seek!
  104.     jnc    MOVIT        ;If seek was good, go in one more cyl,
  105.     ret            ;else return with carry set.
  106. MOVIT:    add    ch,1        ;Next cylinder.
  107.     jnc    INCADJ        ;If register over-
  108.     add    cl, 40h        ;flowed, increase high bits.
  109. INCADJ:    mov    ax, 0C00h    ;Move (seek) to next cylinder.
  110.     int    13h
  111. OUTCYL:
  112.     lea    dx, MESG4
  113.     mov    ah,9
  114.     int    21h
  115.     mov    ax,cx        ;Isolate cylinder #.
  116.     mov    cx,6
  117.     shr    al,cl
  118.     xchg    ah,al
  119.     mov    dh,20h
  120.     CYL2ASC    1000d
  121.     CYL2ASC    100d
  122.     CYL2ASC    10d
  123.     CYL1ASC
  124.     clc
  125.     ret
  126. SEEK    endp
  127. ;==================================================================
  128. PAU    ends
  129.     END    START
  130.